#ifndef MYCONNECTIOSN_H
#define MYCONNECTIOSN_H
#include <list>
#include <string>
#include <mysql/mysql.h>
#include "lock/sem.h"
#include "lock/threadlocker.h"


class MyConnection
{

public:
    static MyConnection* get_instance();
    std::string m_ip;
    int m_port;
    std::string m_usrname;
    std::string  m_password;
    std::string  m_dbname;


private:
    /* data */
    list<MYSQL *> sql_pool;
    int max_conn_size;
    int now_conn_size;
    int free_conn_size;
    sem conn_sem;
    threadlocker locker;
    MyConnection(/* args */);

    
    ~MyConnection();

    

public:
    
    
    void init(std::string  ip,int port,std::string  usrname,std::string  password,std::string  dbname,int connmaxsize);
    //销毁池中连接
    void destroy();
    
    MYSQL * getConn();

    bool * releaseConn(MYSQL * cur_conn);

};
#endif



